<template>
  <tr>
    <td>
      <input type="checkbox" v-model="obj.checked" />
    </td>
    <td>{{ obj.name }}</td>
    <td>{{ obj.price }}</td>
    <td><button @click="add">+</button>{{ obj.num }}<button @click="sub">-</button></td>
    <td>{{ allPrice }}</td>
    <td><button @click="del">删除</button></td>
  </tr>
</template>

<script>
export default {
  name: 'Tr',
  props: ['obj'],
  data () {
    return {}
  },
  methods: {
    add () {
      this.obj.num++
    },
    sub () {
      if (this.obj.num === 1) return
      this.obj.num--
    },
    del () {
      this.$emit('delTr')
    }
  },

  computed: {
    allPrice () {
      return this.obj.num * this.obj.price
    }
  }
}
</script>

<style lang='less' scoped>
</style>
